﻿using NicoView.Model.Service;
using NicoView.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using NicoView.Properties;
using NicoView.Model;
using NicoView.Model.Service.Property;
using NicoView.View.Editor;

namespace NicoView.View
{



    /// <summary>
    /// NicoViewCommentControl.xaml の相互作用ロジック
    /// </summary>
    public partial class NicoViewCommentControl : UserControl
    {
        public NicoViewCommentControl()
        {
            InitializeComponent();
        }




        private void CommentControl_Loaded(object sender, RoutedEventArgs e)
        {
            //xamlではUnderRowDefinitionの高さをなぜか変更できないため、コードビハインドにて高さを変更
            Settings.Default.PropertyChanged += (s, ex) =>
            {
                if (ex.PropertyName == "CommentWriteMode" )
                {

                    fixHeight();
                    
                }
            };

            fixHeight();
        }


        private void fixHeight()
        {
            switch (Settings.Default.CommentWriteMode)
            {
                case NicoViewCommentWriteModeCode.Simple:
                    fixToSimpleWriteControlHeight();
                    break;

                case NicoViewCommentWriteModeCode.CommentArt:
                    fixToCommentArtWriteControlHeight();
                    break;
            }
        }

        private void fixToSimpleWriteControlHeight()
        {
            this.UnderRowDefinition.Height = new GridLength(0, GridUnitType.Auto);
            this.UnderRowDefinition.MinHeight = 0;
        }


        private void fixToCommentArtWriteControlHeight()
        {
            this.UnderRowDefinition.Height = new GridLength(COMMENTART_DEFAULTHEIGHT);
            this.UnderRowDefinition.MinHeight = COMMENTART_DEFAULTHEIGHT;
        }


        private const double COMMENTART_DEFAULTHEIGHT = 162;

    }
}
